// guanghong.ji  2018.03.04

//身份证号校验
function isCardNo(card) 
{  
   // 身份证号码为15位或者18位，15位时全为数字，18位前17位为数字，最后一位是校验位，可能为数字或字符X  
   var reg = /(^\d{15}$)|(^\d{18}$)|(^\d{17}(\d|X|x)$)/;
   if(!reg.test(card))  
   {  
	   console.log("身份证输入不合法");
       return  false;  
   }
   return true;
} 

//校验姓名，姓名最短2个字，目前最长15个字
function isName(name){
    var regName =/^[\u4e00-\u9fa5]{2,15}$/;  
    if(!regName.test(name)){  
    	console.log('真实姓名填写有误');
        return false;  
     } 
     return true;
}

//手机号检验
function isPoneAvailable(mobile) {  
//    var myreg=/^[1][3,4,5,7,8][0-9]{9}$/;  
    var myreg=/^[1][0-9]{10}$/;  
    return myreg.test(mobile);
}

function isNull(str ){
	if(str == null || str == "" ) return true;
	var regu = "^[ ]+$";
	var re = new RegExp(regu);
	return re.test(str);
}

// 弹出提示框
function prompt(prompt, text, timeout){
	if(timeout == null) timeout = 2500;
	prompt.show().text(text);
	setTimeout(function(){
		prompt.hide();
	  }, timeout);
}

//手机号检验
function isUidAvailable(uid) {  
    var myreg=/^[0-9]{6}$/;  
    return myreg.test(uid);
}

function postForResult(obj){
    var ret = null;
    if(obj == null || obj.url == null){
    	console.log("url null");
    	return null;
    }
    $.ajax({
        type: 'POST',
        cache:false, 
        async:false, 
        url: obj.url,
        data: obj,
        dataType: "json",
        success: function(data){
        	ret = data;
        }
    });
    return ret;
}

function time2DateTimeStr(time, splitor){
	var date = new Date(time);
	
    var y = date.getFullYear();  
    
    var m = date.getMonth() + 1;    
    m = m < 10 ? ('0' + m) : m;  
    
    var d = date.getDate();    
    d = d < 10 ? ('0' + d) : d;  
    
    var h = date.getHours();  
    h = h < 10 ? ('0' + h) : h;
    
    var minute = date.getMinutes();  
    minute = minute < 10 ? ('0' + minute) : minute;  
    
    var second = date.getSeconds();  
    second = second < 10 ? ('0' + second) : second;
    
    if(!splitor) splitor = '-';
    
    return y + splitor + m + splitor + d+' '+h+':'+minute+':'+second;    
}

function time2DateStr(time, splitor){
	var date = new Date(time);
	
    var y = date.getFullYear();  
    
    var m = date.getMonth() + 1;    
    m = m < 10 ? ('0' + m) : m;  
    
    var d = date.getDate();    
    d = d < 10 ? ('0' + d) : d;  
    
    return y + splitor + m + splitor + d;    
}

function getAuditStatus(state){
	if(state == 0){
		return '未审核'; 
	}
	else if(state == 1){
		return '审核通过'; 
	}
	else if(state == 2){
		return '审核不通过'; 
	}
	else{
		return '未知';
	}
}